﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CMOSTestLib;
using WFNetLib;

namespace 采集测试
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void Form3_Load(object sender, EventArgs e)
        {
            numericUpDown1.Value = SystemParam.ExposureTest_Ns;
            numericUpDown6.Value = (decimal)SystemParam.ExposurePointThreshold;

            numericUpDown2.Value = SystemParam.L;
            numericUpDown3.Value = SystemParam.Step2_len;
            numericUpDown4.Value = (decimal)SystemParam.DarkPointPer;
            numericUpDown5.Value = (decimal)SystemParam.LightPointPer;

            numericUpDown7.Value = Calc1.k1;
            numericUpDown8.Value = Calc1.k2;

            numericUpDown10.Value = (decimal)Calc1.percent_base;
            numericUpDown9.Value = (decimal)Calc1.percent;

            numericUpDown13.Value = int.Parse(iniFileOP.Read("System Setting", "FPN_Per"));
            numericUpDown12.Value = int.Parse(iniFileOP.Read("System Setting", "FPN_Ns"));

            numericUpDown11.Value = int.Parse(iniFileOP.Read("System Setting", "FPN_L"));
            numericUpDown14.Value = int.Parse(iniFileOP.Read("System Setting", "FPN_Len"));

            numericUpDown15.Value = SystemParam.Dark_N;
            numericUpDown16.Value = SystemParam.PicDelay;
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            SystemParam.ExposureTest_Ns = (int)numericUpDown1.Value;
            Calc1.k1 = (int)numericUpDown7.Value;
            Calc1.k2 = (int)numericUpDown8.Value;
            SystemParam.ExposurePointThreshold = (double)numericUpDown6.Value;

            SystemParam.L = (ushort)numericUpDown2.Value;
            SystemParam.Step2_len = (ushort)numericUpDown3.Value;
            SystemParam.DarkPointPer = (double)numericUpDown4.Value;
            SystemParam.LightPointPer = (double)numericUpDown5.Value;

            Calc1.percent_base = (double)numericUpDown10.Value;
            Calc1.percent = (double)numericUpDown9.Value;

            iniFileOP.Write("System Setting", "ExposureTest_Ns",SystemParam.ExposureTest_Ns.ToString());
            iniFileOP.Write("System Setting", "k1", Calc1.k1.ToString());
            iniFileOP.Write("System Setting", "k2", Calc1.k2.ToString());
            iniFileOP.Write("System Setting", "percent_base", Calc1.percent_base.ToString());
            iniFileOP.Write("System Setting", "percent", Calc1.percent.ToString());

            iniFileOP.Write("System Setting", "ExposurePointThreshold", SystemParam.ExposurePointThreshold.ToString("F1"));

            iniFileOP.Write("System Setting", "L", SystemParam.L.ToString());
            iniFileOP.Write("System Setting", "Step2_len", SystemParam.Step2_len.ToString());
            iniFileOP.Write("System Setting", "DarkPointPer", SystemParam.DarkPointPer.ToString("F1"));
            iniFileOP.Write("System Setting", "LightPointPer", SystemParam.LightPointPer.ToString("F1"));


            iniFileOP.Write("System Setting", "FPN_Per", ((int)(numericUpDown13.Value)).ToString());
            iniFileOP.Write("System Setting", "FPN_NS", ((int)(numericUpDown12.Value)).ToString());
            iniFileOP.Write("System Setting", "FPN_L", ((int)(numericUpDown11.Value)).ToString());
            iniFileOP.Write("System Setting", "FPN_Len", ((int)(numericUpDown14.Value)).ToString());

            iniFileOP.Write("System Setting", "Dark_N", SystemParam.Dark_N.ToString());
            iniFileOP.Write("System Setting", "PicDelay", SystemParam.PicDelay.ToString());
            this.Close();
        }
    }
}
